Method and apparatus for referencing a constant pool in a java virtual machine

ABSTRACT

A method, apparatus, and computer instructions for referencing a constant pool. A determination is made as to whether a bytecode references the constant pool. A relative offset to the constant pool is identified for the bytecode, in response to the bytecode referencing the constant pool. The bytecode is then replaced with a new bytecode containing the relative offset. The relative offset is used to reference the constant pool.

BACKGROUND OF THE INVENTION

1. Technical Field

The present invention relates generally to an improved data processingsystem and in particular to a method and apparatus for processing data.Still more particularly, the present invention provides a method,apparatus, and computer instructions for referencing a constant pool.

2. Description of Related Art

Java® is an object-oriented programming language designed to generateapplications that can run on all different types of data processingsystems without modification. Developed by Sun Microsystems, Inc. Java®has been promoted and geared heavily for the Web, both for public Websites and intranets. Java® programs can be called from within H®Ldocuments or launched standalone. When a Java® program called from a Webpage runs on a user's machine, this program is called a “Java® applet.”When a Java® program is run on a Web server, it is called a “servlet.” AJava® program running on a data processing system as a standalone nonWeb-based program is simply referred to as a “Java® application.” Java®,JVM® and all Java®-based trademarks are trademarks of sun Microsystems,Inc. in the United States, other countries, or both.

Java® uses an intermediate language called “bytecode.” Bytecodes arenonspecific to hardware platforms. The source code of a Java® program iscompiled into bytecode, which can be moved from one hardware platform toanother. In order to run the Java® program, it must be compiled intomachine code first. The compilation is done either ahead of time like aC/C++ program, a line at a time like an interpreter, or as needed usinga just-in-time compiler.

In executing a Java® program, such as a Java® applet, the Web browserinvokes a Java® virtual machine (JVM®). This component translatesbytecodes into machine code for execution. As a result, Java® programsare not dependent on any specific hardware and will run in any dataprocessing system with a Java® virtual machine.

Many Java® bytecodes refer to a constant pool. A constant pool is acollection of data that is stored in the class area in the Java® virtualmachine. The constant pool is an ordered set of constants used by aclass or interface, including literals and symbolic references to types,fields, and methods. The constant pool plays a central role in thedynamic linking of Java® programs. The data in the constant poolprovides information describing how a bytecode is to be executed. Forthe Java® virtual machine to reference the constant pool, the Java®virtual machine must maintain a reference to the start of the constantpool.

Additionally, it is often important for the Java® virtual machine toknow information about the currently executing Java® method. Thisinformation may be derived from the program counter, but this processcan involve a performance penalty. It is desirable to be able to accessboth the constant pool and the currently executing method in anefficient manner.

One solution to this problem is for the Java® virtual machine tomaintain a pointer to the constant pool and a pointer to the currentmethod at all times. This solution generates a new problem because twoactive pointers are maintained. The pointers reduce the number ofprocessor registers available for other uses and increases the amount ofstate data saved and restored on Java® method invocations.

Another solution involves the Java® virtual machine maintaining apointer to the method at all times and deriving a pointer to theconstant pool when access to the constant pool is needed. This solutiontrades a penalty to access the method pointer for a penalty to accessthe constant pool. Therefore, it would be advantageous to have animproved method, apparatus, and computer instructions for a Java®virtual machine to reference a constant pool.

SUMMARY OF THE INVENTION

The present invention provides a method, apparatus, and computerinstructions for referencing a constant pool. A determination is made asto whether a bytecode references the constant pool. A relative offset tothe constant pool is identified for the bytecode, in response to thebytecode referencing the constant pool. The bytecode is then replacedwith a new bytecode containing the relative offset. The relative offsetis used to reference the constant pool.

BRIEF DESCRIPTION OF THE DRAWINGS

The novel features believed characteristic of the invention are setforth in the appended claims. The invention itself, however, as well asa preferred mode of use, further objectives and advantages thereof, willbest be understood by reference to the following detailed description ofan illustrative embodiment when read in conjunction with theaccompanying drawings, wherein:

FIG. 1 is a pictorial representation of a data processing system inwhich the present invention may be implemented in accordance with apreferred embodiment of the present invention;

FIG. 2 is a block diagram of a data processing system in which thepresent invention may be implemented;

FIG. 3 is a block diagram illustrating the relationship of softwarecomponents operating within a computer system that may be implemented inthe present invention;

FIG. 4 is a block diagram of a JVM® in accordance with a preferredembodiment of the present invention;

FIG. 5 is a diagram illustrating a class structure overview inaccordance with a preferred embodiment of the present invention;

FIG. 6 is a diagram illustrating a method structure and constant pool inwhich bytecodes are rewritten in accordance with a preferred embodiment;

FIG. 7 is a flowchart of a process for rewriting bytecodes in accordancewith a preferred embodiment of the present invention; and

FIG. 8 is a flowchart of a process for processing bytecodes duringexecution of a Java® program in accordance with a preferred embodimentof the present invention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT

With reference now to the figures and in particular with reference toFIG. 1, a pictorial representation of a data processing system in whichthe present invention may be implemented is depicted in accordance witha preferred embodiment of the present invention. A computer 100 isdepicted which includes system unit 102, video display terminal 104,keyboard 106, storage devices 108, which may include floppy drives andother types of permanent and removable storage media, and mouse 110.Additional input devices may be included with personal computer 100,such as, for example, a joystick, touchpad, touch screen, trackball,microphone, and the like. Computer 100 can be implemented using anysuitable computer, such as an IBM eServer computer or IntelliStationcomputer, which are products of International Business MachinesCorporation, located in Armonk, N.Y. Although the depictedrepresentation shows a computer, other embodiments of the presentinvention may be implemented in other types of data processing systems,such as a network computer. Computer 100 also preferably includes agraphical user interface (GUI) that may be implemented by means ofsystems software residing in computer readable media in operation withincomputer 100.

With reference now to FIG. 2, a block diagram of a data processingsystem is shown in which the present invention may be implemented. Dataprocessing system 200 is an example of a computer, such as computer 100in FIG. 1, in which code or instructions implementing the processes ofthe present invention may be located. Data processing system 200 employsa peripheral component interconnect (PCI) local bus architecture.Although the depicted example employs a PCI bus, other bus architecturessuch as Accelerated Graphics Port (AGP) and Industry StandardArchitecture (ISA) may be used. Processor 202 and main memory 204 areconnected to PCI local bus 206 through PCI bridge 208. PCI bridge 208also may include an integrated memory controller and cache memory forprocessor 202. Additional connections to PCI local bus 206 may be madethrough direct component interconnection or through add-in connectors.In the depicted example, local area network (LAN) adapter 210, smallcomputer system interface SCSI host bus adapter 212, and expansion businterface 214 are connected to PCI local bus 206 by direct componentconnection. In contrast, audio adapter 216, graphics adapter 218, andaudio/video adapter 219 are connected to PCI local bus 206 by add-inboards inserted into expansion slots. Expansion bus interface 214provides a connection for a keyboard and mouse adapter 220, modem 222,and additional memory 224. SCSI host bus adapter 212 provides aconnection for hard disk drive 226, tape drive 228, and CD-ROM drive230. Typical PCI local bus implementations will support three or fourPCI expansion slots or add-in connectors.

An operating system runs on processor 202 and is used to coordinate andprovide control of various components within data processing system 200in FIG. 2. The operating system may be a commercially availableoperating system such as Windows XP, which is available from MicrosoftCorporation. An object oriented programming system such as Java® may runin conjunction with the operating system and provides calls to theoperating system from Java® programs or applications executing on dataprocessing system 200. “Java®” is a trademark of Sun Microsystems, Inc.Instructions for the operating system, the object-oriented programmingsystem, and applications or programs are located on storage devices,such as hard disk drive 226, and may be loaded into main memory 204 forexecution by processor 202.

Those of ordinary skill in the art will appreciate that the hardware inFIG. 2 may vary depending on the implementation. Other internal hardwareor peripheral devices, such as flash read-only memory (ROM), equivalentnonvolatile memory, or optical disk drives and the like, may be used inaddition to or in place of the hardware depicted in FIG. 2. Also, theprocesses of the present invention may be applied to a multiprocessordata processing system.

For example, data processing system 200, if optionally configured as anetwork computer, may not include SCSI host bus adapter 212, hard diskdrive 226, tape drive 228, and CD-ROM 230. In that case, the computer,to be properly called a client computer, includes some type of networkcommunication interface, such as LAN adapter 210, modem 222, or thelike. As another example, data processing system 200 may be astand-alone system configured to be bootable without relying on sometype of network communication interface, whether or not data processingsystem 200 comprises some type of network communication interface. As afurther example, data processing system 200 may be a personal digitalassistant (PDA), which is configured with ROM and/or flash ROM toprovide non-volatile memory for storing operating system files and/oruser-generated data.

The depicted example in FIG. 2 and above-described examples are notmeant to imply architectural limitations. For example, data processingsystem 200 also may be a notebook computer or hand held computer inaddition to taking the form of a PDA. Data processing system 200 alsomay be a kiosk or a Web appliance.

The processes of the present invention are performed by processor 202using computer implemented instructions, which may be located in amemory such as, for example, main memory 204, memory 224, or in one ormore peripheral devices 226-230.

With reference now to FIG. 3, a block diagram illustrates therelationship of software components operating within a computer systemthat may be used to implement the present invention. Java®-based system300 contains platform specific operating system 302 that provideshardware and system support to software executing on a specific hardwareplatform. JVM® 304 is one software application that may execute inconjunction with the operating system. JVM® 304 provides a Java®run-time environment with the ability to execute Java® application orapplet 306, which is a program, servlet, or software component writtenin the Java® programming language. The computer system in which JVM® 304operates may be similar to data processing system 200 in FIG. 2 orcomputer 100 in FIG. 1 described above. However, JVM® 304 may beimplemented in dedicated hardware on a so-called Java® chip,Java®-on-silicon, or Java® processor with an embedded picoJava® core.

At the center of a Java® run-time environment is the JVM®, whichsupports all aspects of Java®'s environment, including its architecture,security features, mobility across networks, and platform independence.

The JVM® is a virtual computer, such as a computer that is specifiedabstractly. The specification defines certain features that every JVM®must implement, with some range of design choices that may depend uponthe platform on which the JVM® is designed to execute. For example, allJVM®s must execute Java® bytecodes and may use a range of techniques toexecute the instructions represented by the bytecodes. A JVM® may beimplemented completely in software or somewhat in hardware. Thisflexibility allows different JVM®s to be designed for mainframecomputers and PDAs.

The JVM® is the name of a virtual computer component that actuallyexecutes Java® programs. Java® programs are not run directly by thecentral processor but instead by the JVM®, which is itself a piece ofsoftware running on the processor. The JVM® allows Java® programs to beexecuted on a different platform as opposed to only the one platform forwhich the code was compiled. Java® programs are compiled for the JVM®.In this manner, Java® is able to support applications for many types ofdata processing systems, which may contain a variety of centralprocessing units and operating system architectures. To enable a Java®application to execute on different types of data processing systems, acompiler typically generates an architecture-neutral file format—thecompiled code is executable on many processors, given the presence ofthe Java® run-time system.

The Java® compiler generates bytecode instructions that are nonspecificto a particular computer architecture. A bytecode is a machineindependent code generated by the Java® compiler and executed by a Java®interpreter. A Java® interpreter is part of the JVM® that alternatelydecodes and interprets a bytecode or bytecodes. These bytecodeinstructions are designed to be easy to interpret on any computer andeasily translated on the fly into native machine code. Bytecodes may betranslated into native code by a just-in-time compiler or JIT.

A JVM® loads class files and executes the bytecodes within them. Theclass files are loaded by a class loader in the JVM®. The class loaderloads class files from an application and the class files from the Java®application programming interfaces (APIs) which are needed by theapplication. The execution engine that executes the bytecodes may varyacross platforms and implementations.

One type of software-based execution engine is a just-in-time compiler.With this type of execution, the bytecodes of a method are compiled tonative machine code upon successful fulfillment of some type of criteriafor compiling a method. The native machine code for the method is thencached and reused upon the next invocation of the method. The executionengine also may be implemented in hardware and embedded on a chip sothat the Java® bytecodes are executed natively. JVM®s usually interpretbytecodes, but JVM®s may also use other techniques, such as just-in-timecompiling, to execute bytecodes.

When an application is executed on a JVM® that is implemented insoftware on a platform-specific operating system, a Java® applicationmay interact with the host operating system by invoking native methods.A Java® method is written in the Java® language, compiled to bytecodes,and stored in class files. A native method is written in some otherlanguage and compiled to the native machine code of a particularprocessor. Native methods are typically stored in a dynamically linkedlibrary whose exact form is platform specific.

With reference now to FIG. 4, a block diagram of a JVM® is depicted inaccordance with a preferred embodiment of the present invention. JVM®400 includes class loader subsystem 402, which is a mechanism forloading types, such as classes and interfaces, given fully qualifiednames. JVM® 400 also contains runtime data areas 404, execution engine406, native method interface 408, and memory management 410. Executionengine 406 is a mechanism for executing instructions contained in themethods of classes loaded by class loader subsystem 402. Executionengine 406 may be, for example, Java® interpreter 412 or just-in-timecompiler 414. Native method interface 408 allows access to resources inthe underlying operating system. Native method interface 408 may be, forexample, the Java® Native Interface (JNI).

Runtime data areas 404 contain native method stacks 416, Java® stacks418, PC registers 420, method area 422, and heap 424. These differentdata areas represent the organization of memory needed by JVM® 400 toexecute a program.

Java® stacks 418 are used to store the state of Java® methodinvocations. When a new thread is launched, the JVM® creates a new Java®stack for the thread. The JVM® performs only two operations directly onJava® stacks: it pushes and pops frames. A thread's Java® stack storesthe state of Java® method invocations for the thread. The state of aJava® method invocation includes its local variables, the parameterswith which it was invoked, its return value, if any, and intermediatecalculations. Java® stacks are composed of stack frames. A stack framecontains the state of a single Java® method invocation. When a threadinvokes a method, the JVM® pushes a new frame onto the Java® stack ofthe thread. When the method completes, the JVM® pops the frame for thatmethod and discards it. The JVM® does not have any registers for holdingintermediate values; any Java® instruction that requires or produces anintermediate value uses the stack for holding the intermediate values.In this manner, the Java® instruction set is well-defined for a varietyof platform architectures.

Program counter (PC) registers 420 are used to indicate the nextinstruction to be executed. Each instantiated thread gets its own PCregister and Java® stack. If the thread is executing a JVM® method, thevalue of the PC register indicates the next instruction to execute. Ifthe thread is executing a native method, then the contents of the PCregister are undefined. Native method stacks 416 stores the state ofinvocations of native methods. The state of native method invocations isstored in an implementation-dependent way in native method stacks,registers, or other implementation-dependent memory areas. In some JVM®implementations, native method stacks 416 and Java® stacks 418 arecombined.

Method area 422 contains class data while heap 424 contains allinstantiated objects. The constant pool is located in method area 422 inthese examples. The JVM® specification strictly defines data types andoperations. Most JVM®s choose to have one method area and one heap, eachof which are shared by all threads running inside the JVM®, such as JVM®400. When JVM® 400 loads a class file, it parses information about atype from the binary data contained in the class file. JVM® 400 placesthis type of information into the method area. Each time a classinstance or array is created, the memory for the new object is allocatedfrom heap 424. JVM® 400 includes an instruction that allocates memoryspace within the memory for heap 424 but includes no instruction forfreeing that space within the memory. Memory management 410 in thedepicted example manages memory space within the memory allocated toheap 424. Memory management 410 may include a garbage collector, whichautomatically reclaims memory used by objects that are no longerreferenced. Additionally, a garbage collector also may move objects toreduce heap fragmentation.

The present invention provides a mechanism to reference items in aconstant pool through a method pointer, rather than a constant poolpointer. This mechanism allows for maintaining a pointer to the methodat all times and deriving the pointer to the constant pool only whennecessary. This mechanism of the present invention does not negativelyimpact the performance of most Java® programs.

Specifically, as Java® class files are loaded into the Java® virtualmachine, the Java® virtual machine analyzes the bytecodes in the classfiles and rewrites them in accordance with a preferred embodiment of thepresent invention. In the illustrative examples, certain bytecodes whichrefer to the constant pool are replaced with new bytecodes, which areundefined in the Java® virtual machine specification. Although all typesof bytecodes which include constant pool may be rewritten using themechanism of the present invention, only some types of bytecodes mightbe rewritten using this mechanism. For example, the bytecodes selectedfor rewriting may be those that are most common or critical for a Java®program.

The new versions of the bytecodes are equivalent to the specifiedversions of the bytecodes, except that the constant pool index in thebytecode is an offset relative to the current method pointer rather thanan offset relative to the beginning of the constant pool.

To calculate the offset relative to the method pointer, method pointersare stored in memory in a location relative to the constant pool inwhich the offset can be calculated while the class files are beingloaded by the class loader. In the illustrative embodiment, the methodpointers would be placed immediately before the constant pool. Of coursein another illustrative embodiment, the method pointers and structuresmay be placed after the constant pool or with other data between themethod pointers and the constant pool.

Calculating the offset from a method pointer to an indexed constant poolentry requires knowing the size of each method pointer and the number ofmethod pointers stored between the current method pointer of interestand the beginning of the constant pool. Of course, many other layoutschemes are also possible, depending on the implementation.

In certain, unusual, instances, it may be impossible to replace theoriginal bytecodes with method-relative versions. Changing the relativebase may cause the constant pool offset to increase. This may result inan offset which is too large to represent within the 8 or 16-bitconstant pool index encoded within each bytecode. In this case, thebytecode is left unchanged and the slower, but still correct, and theconstant pool relative bytecode is used.

Turning now to FIG. 5, a diagram illustrating a class structure overviewis depicted in accordance with a preferred embodiment of the presentinvention. Class structure 500 includes fixed size class data 502,variable size vtable 504, methods 506, constant pool 508, andmiscellaneous variable size data 510. In these examples, thisinformation is located in method area 422 within JVM® 400 in FIG. 4.Fixed size class data 502 includes class modifiers, a pointer to theclass name, the number of fields in the class, a pointer to a structuredescribing the fields, the number of methods in the class, a pointer toa structure describing the methods of the class, and other fixed sizeelements which describe the class. Variable size vtable 504 is a virtualdispatch table—an array of method pointers used to implement virtualdispatching of methods. Methods 506 contain the methods loaded by theclass loader. Constant pool 508 is an ordered set of constants used bythe type, including literals and symbolic references to types, fields,and methods. Miscellaneous variable size data 510 consists of variablesize data structures which help describe the class. Typically these arereferred to by pointers in the fixed size class data section 502.

Methods 506 in class structure 500 initially have an offset relative tothe beginning of constant pool 508. These bytecodes are replaced withones that contain an offset relative to the method pointer for thebytecode. As shown, methods 506 are located immediately before constantpool 508. Of course, methods 506 may be located after constant pool 508or before constant pool 508 with some other data structure being locatedbetween these two structures. In this illustrative example, themechanism of the present invention is implemented in a class loader,such as class loader subsystem 402 in FIG. 4. In other manifestations,the mechanism of the present invention could be implemented in aseparate executable which preprocesses class files and translates theminto an JVM® implementation-specific data format for faster loading (forinstance, the SmarkLinker tool which forms part of Websphere StudioDevice Developer).

Turning now to FIG. 6, a diagram illustrating a method structure andconstant pool in which bytecodes are rewritten is depicted in accordancewith a preferred embodiment. In this figure, method 600 is locatedwithin method structure 601. Method 600 includes four slots. These slotscontain a pointer. Each pointer is a 32 or 64 bit pointer in theillustrative examples. These slots contain constant pool pointer 602,bytecodes 604, native address 606, and method specific information 608.Constant pool pointer 602 allows access to the class with the currentmethod. Bytecodes 604 includes offsets relative to the beginning of theconstant pool. Native address 606 contains a pointer to machineinstructions for executing the method. Method specific information 608contains data used by the native code.

The mechanism of the present invention rewrites bytecodes 604 to containan offset from the method pointer to an entry within constant pool 610.Constant pool 610 contains slot 612, which is a slot identifying thebeginning of constant pool 610. Constant pool pointer 602 points toconstant pointer pool slot 612, which is a special slot in constant pool610 used to indicate the beginning of constant pool 610. In rewritingbytecodes 604, the original bytecode in the slot is invokevirtual 1 620.The offset for this bytecode has a value of 1. When rewritten, therewritten bytecode is now as follows: invokevirtual_method_relative x+1622.

The original bytecode contained an offset having a value of 1 relativeto the beginning of the constant pool. In this example, the offset ofthe rewritten bytecode is x+1 and points to constant pool slot 614 fromthe current method pointer, rather than from the beginning of constantpool 610.

In the original bytecode, in bytecodes 604, this slot is identified byusing constant pool pointer 602 to identify the beginning of constantpool 610 and then using the index of 1 to identify constant pool slot 1.When the original bytecode in bytecodes 604 is rewritten, the index of 1is added to a value of x to provide an offset relative to the methodpointer.

Assuming that each method structure contained four slots and that twomethod structures are present before method 600 relative to constantpool 610, a value of 12 is identified for x. As a result, the offset ofx+1 for the rewritten bytecode in bytecodes 604 is 13. This offset isused to provide an offset to identify constant pool slot 614 based oncurrent method pointer 616, which points to the beginning of method 600in this example.

In this manner, only a single method pointer needs to be maintained. Byreducing the number of pointers maintained, resources, such asregisters, are conserved. Additionally, the amount of time needed toderive pointers is reduced.

With reference now to FIG. 7, a flowchart of a process for rewritingbytecodes is depicted in accordance with a preferred embodiment of thepresent invention. The process illustrated in FIG. 7 may be implementedin a class loader, such as class loader subsystem 402 in FIG. 4.

The process begins by fetching the next bytecode (step 700). Next, adetermination is made as to whether the bytecode refers to the constantpool offset (step 702). If the bytecode does refer to the constant pool,then the method-relative constant pool offset is calculated (step 704).The calculation may be made in the illustrative examples by firstcounting the methods present. The size of each method also isdetermined. The number of methods after the one referred to by thebytecode is identified. This value is multiplied by the size of themethods. The original index is added to this value to generate theoffset for the bytecode to be rewritten.

Next, a determination is made as to whether this is an ldc bytecode(step 706). An ldc bytecode is a special case taken into account inthese illustrative examples. This bytecode uses 8 bits, rather than 16bits. As a result, this type of bytecode has a lower value for offsets.If this bytecode is not a ldc bytecode, then a determination is made asto whether the new offset is less than or equal to 65535 (step 708). Ifthe new offset is not less than or equal to 65535, then the processreturns to step 700 as described above. Otherwise, the bytecode isreplaced with the new bytecode and the calculated offset that isrelative to the method pointer (step 710) with the process thenreturning to step 700.

Referring back to step 702, if the bytecode does not refer to theconstant pool offset, then the process proceeds to step 700 as describedabove. In step 706, if the bytecode is an ldc bytecode, then adetermination is made as to whether the new offset is less than or equalto 255 (step 712). If the new offset is less than or equal to 255, thenthe process proceeds to step 710 as described above. If the new offsetis not less than or equal to 255, then the process proceeds to step 700as described above.

With reference now to FIG. 8, a flowchart of a process for processingbytecodes during execution of a Java® program is depicted in accordancewith a preferred embodiment of the present invention. The processillustrated in FIG. 8 may be implemented in an execution engine, such asexecution engine 406 in FIG. 4. More specifically, this process may beimplemented in interpreter 412 in FIG. 4.

The process begins by fetching the next bytecode for execution (step800). Next, if any bytecode parameters are present, they are read (step802). Then, a determination is made as to whether the bytecodereferences the constant pool (step 804). If the bytecode does referencethe constant pool, then a determination is made as to whether thebytecode method is relative (step 810).

If the bytecode is method-relative, then the parameter is added to thecurrent method pointer (step 812). In this case, the parameter is anoffset. Then, a value is fetched from the constant pool (step 818).Next, bytecode action is processed using the value from the constantpool (step 806). Then, the bytecode successor is determined (step 808)with the process then proceeding to step 800 as described above.

Referring back to step 804, if the bytecode does not reference theconstant pool, then the process proceeds to step 806 as described above.With reference back to step 810, if the bytecode is not method-relative,then the constant pool pointer is derived from the current methodpointer (step 814). Then, the parameter is added to the constant poolpointer (step 816) with the process then proceeding to step 818 asdescribed above.

Thus, the present invention provides an improved method, apparatus, andcomputer instructions for referencing a constant pool. The mechanism ofthe present invention rewrites bytecodes with new ones that use anoffset that is relative to a method pointer, rather than the beginningof the constant pool. In this manner, only one pointer needs to bemaintained. Thus, the amount of resources and calculations are reducedthrough the mechanism of the present invention.

It is important to note that while the present invention has beendescribed in the context of a fully functioning data processing system,those of ordinary skill in the art will appreciate that the processes ofthe present invention are capable of being distributed in the form of acomputer readable medium of instructions and a variety of forms and thatthe present invention applies equally regardless of the particular typeof signal bearing media actually used to carry out the distribution.Examples of computer readable media include recordable-type media, suchas a floppy disk, a hard disk drive, a RAM, CD-ROMs, DVD-ROMs, andtransmission-type media, such as digital and analog communicationslinks, wired or wireless communications links using transmission forms,such as, for example, radio frequency and light wave transmissions. Thecomputer readable media may take the form of coded formats that aredecoded for actual use in a particular data processing system.

The description of the present invention has been presented for purposesof illustration and description, and is not intended to be exhaustive orlimited to the invention in the form disclosed. Many modifications andvariations will be apparent to those of ordinary skill in the art. Theembodiment was chosen and described in order to best explain theprinciples of the invention, the practical application, and to enableothers of ordinary skill in the art to understand the invention forvarious embodiments with various modifications as are suited to theparticular use contemplated.

1. A method in a data processing system for referencing a constant pool,the method comprising: determining whether a bytecode references theconstant pool; responsive to the bytecode referencing the constant pool,identifying a relative offset to the constant pool for the bytecodeusing a size of each method pointer and a number of method pointerspresent between a current method pointer for the bytecode and abeginning of the constant pool, wherein the relative offset is a numberof slots separating the bytecode and the constant pool; and replacingthe bytecode with a new bytecode containing the relative offset, whereinthe relative offset is used to reference the constant pool.
 2. Themethod of claim 1 further comprising: responsive to receiving a selectedbytecode for execution, determining whether the selected bytecodereferences the constant pool; responsive to the selected bytecodereferencing the constant pool, adding a selected relative offset for theselected bytecode to a current method pointer to form a modifiedpointer; and fetching a value from the constant pool using the modifiedpointer.
 3. The method of claim 1, wherein the identifying step andreplacing step are initiated during loading of class files.
 4. Themethod of claim 1, wherein the determining step, the identifying step,and the replacing step are performed in a class loader within a Javavirtual machine.
 5. The method of claim 1 further comprising: responsiveto the bytecode referencing the constant pool, determining whether therelative offset is present for a selected bytecode; and deriving aconstant pool pointer from a current method pointer if the relativeoffset is absent.
 6. The method of claim 1, wherein methods associatedwith the bytecode are located before the constant pool.